css: Use %f, not %.17f
authorBenjamin Otte <otte@redhat.com>
Wed, 29 May 2019 12:29:25 +0000 (14:29 +0200)
committerBenjamin Otte <otte@redhat.com>
Wed, 29 May 2019 12:30:13 +0000 (14:30 +0200)
The testusite failures explain why:
We don't want to print "1.00000000000000000", but "1".

gdk/gdkrgba.c
gsk/gskrendernodeparser.c
gtk/css/gtkcsstokenizer.c
gtk/gtkcssdimensionvalue.c

index a9b9365e0e899385e0392f42847e466ba6789058..b52e0254e6f101f4419fe0da99cb4dcaead80909 100644 (file)
@@ -386,7 +386,7 @@ gdk_rgba_to_string (const GdkRGBA *rgba)
     {
       gchar alpha[G_ASCII_DTOSTR_BUF_SIZE];
 
-      g_ascii_formatd (alpha, G_ASCII_DTOSTR_BUF_SIZE, "%.17f", CLAMP (rgba->alpha, 0, 1));
+      g_ascii_formatd (alpha, G_ASCII_DTOSTR_BUF_SIZE, "%g", CLAMP (rgba->alpha, 0, 1));
 
       return g_strdup_printf ("rgba(%d,%d,%d,%s)",
                               (int)(0.5 + CLAMP (rgba->red, 0., 1.) * 255.),
index 78554a3921779c4266ecd453d2976d6c594f4354..59b8a4292cb4ff000bbe7e53624c570c122b2ff1 100644 (file)
@@ -1527,7 +1527,7 @@ string_append_double (GString *string,
 {
   char buf[G_ASCII_DTOSTR_BUF_SIZE];
 
-  g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%.17f", d);
+  g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%g", d);
   g_string_append (string, buf);
 }
 
index a9cab554a3cf61333061def744bb055fc59f7c01..c9a38566574b6ee636f05fae8e56f5526179d37b 100644 (file)
@@ -406,7 +406,7 @@ gtk_css_token_print (const GtkCssToken *token,
       /* fall through */
     case GTK_CSS_TOKEN_SIGNLESS_INTEGER_DIMENSION:
     case GTK_CSS_TOKEN_DIMENSION:
-      g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%.17f", token->dimension.value);
+      g_ascii_dtostr (buf, G_ASCII_DTOSTR_BUF_SIZE, token->dimension.value);
       g_string_append (string, buf);
       append_ident (string, token->dimension.dimension);
       break;
index 626c0ac2cb128df1f874407def467ec3c7262b4f..4efdf13ef269546715054ccd5631b7d45fc58f90 100644 (file)
@@ -198,7 +198,7 @@ gtk_css_value_dimension_print (const GtkCssValue *number,
     g_string_append (string, "infinite");
   else
     {
-      g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%.17f", number->value);
+      g_ascii_dtostr (buf, sizeof (buf), number->value);
       g_string_append (string, buf);
       if (number->value != 0.0)
         g_string_append (string, names[number->unit]);